import java.awt.*;

class Harmful extends GameElement {
    public Harmful(float x, float y, int size, Color color, float effect, float duration) {
        super(x, y, size, color, effect, duration);
    }


    @Override
    public boolean update() {
        // 先执行基本漂浮行为
        super.update();

        // 索敌逻辑 - 缓慢向胚胎移动
        Embryo embryo = GameState.getInstance().getEmbryo();
        float dx = embryo.getX() - x;
        float dy = embryo.getY() - y;
        float dist = (float) Math.sqrt(dx * dx + dy * dy);

        if (dist > 0) {
            // 以30%的漂浮速度向胚胎移动
            float seekForce = 0.3f;
            x += (dx / dist) * floatSpeed * seekForce;
            y += (dy / dist) * floatSpeed * seekForce;
        }

        return age < duration;
    }
}
